<juci-layout-with-sidebar>
	<div ng-controller="SettingsUpgradeCtrl">
		<juci-config-section> 
			<juci-config-heading>{{ 'Firmware Upgrade' | translate }}</juci-config-heading>
			<juci-config-info>{{ 'settings.upgrade.info' | translate }}</juci-config-info>
			<juci-config-lines>
				<juci-config-line title="{{'Current Firmware Version'|translate}}">
					<strong>{{current_version}}</strong>
				</juci-config-line>
			</juci-config-lines>
		</juci-config-section>
		<juci-config-section ng-show="system.upgrade.fw_check_url.value">
			<h2>{{'Online Update'|translate}}</h2>
			<p>{{'settings.upgrade.online.info'|translate}}</p>
			<juci-config-lines>
				<juci-config-line title="{{onlineUpgrade}}">
					<button ng-hide="onlineUpgradeAvailable" class="btn btn-lg btn-default" ng-click="onOnlineCheck()">
						<i class="fa fa-spinner fa-spin" ng-show="onlineCheckInProgress"></i>{{'Check for Upgrade'|translate}}</button>
					<button ng-show="onlineUpgradeAvailable" class="btn btn-lg btn-default" ng-click="onUpgradeOnline()">{{'Install Upgrade'|translate}}</button>
				</juci-config-line>
			</juci-config-lines>
		</juci-config-section>
		<juci-config-section ng-show="system.upgrade.fw_usb_path.value">
			<h2>{{'USB Firmware Upgrade'|translate}}</h2>
			<p>{{'settings.upgrade.usb.info'|translate}}</p>
			<juci-config-lines>
				<juci-config-line title="{{usbUpgrade}}" ng-show="usbUpgradeAvailable">
					<button class="btn btn-lg btn-default" ng-click="onUpgradeUSB()">{{'Install Upgrade'|translate}}</button>
				</juci-config-line>
				<juci-config-line title="{{usbUpgrade}}" ng-hide="usbUpgradeAvailable">
					<button class="btn btn-lg btn-default" ng-click="onCheckUSB()"><i class="fa fa-spinner fa-spin" ng-show="usbCheckInProgress"></i>{{'Check for Upgrade'|translate}}</button>
				</juci-config-line>
			</juci-config-lines>
		</juci-config-section>
		<juci-config-section>
			<h2>{{'Manual Firmware Upgrade'|translate}}</h2>
			<p>{{'settings.upgrade.manual.info'|translate}}</p>
			<iframe name="postiframe" id="postiframe" style="display: none;" ></iframe>
			<form target="postiframe" name="uploadForm" action="/cgi-bin/juci-upload" method="post" enctype="multipart/form-data" >
				<input type="hidden" name="sessionid" value="{{sessionID}}" />
				<input type="hidden" name="filename" value="{{uploadFilename}}" />
				<juci-config-lines>
					<juci-config-line title="{{'Pick firmware file to upload'|translate}}">
						<input type="file" class="btn btn-default btn-file"  name="filedata" ng-model="uploadFile"/>
					</juci-config-line>
					<juci-config-line title="{{'Start upgrade'|translate}}">
						<button ng-click="onUploadUpgrade()" class="btn btn-lg btn-default" ng-class="{ 'disabled': uploadFile }">{{'Upgrade'|translate}}</button>
					</juci-config-line>
				</juci-config-lines>
			</form>
		</juci-config-section>
		<!-- commenting this for now. But if it is necessary to show these then add a config option for this page to show/hide them -->
		<!--<p class="alert alert-warning" ng-hide="system.upgrade.fw_check_url.value" translate>Online upgrade is disabled</p>
		<p class="alert alert-warning" ng-hide="system.upgrade.fw_usb_path.value" translate>USB upgrade is disabled</p>-->
		<modal title="Do you want to keep your configuration?" ng-show="showConfirm" on-accept="onConfirmKeep()" on-dismiss="onConfirmWipe()" accept-label="Yes" dismiss-label="No">
			<p translate>If you answer yes then your confiruation will be saved before the upgrade and restored after the upgrade has completed. If you choose 'no' then all your current confiration will be reset to defaults.</p>
		</modal>
		<modal title="Firmware Upgrade" ng-show="showUpgradeStatus">
			<center>
				<p style="text-align: center;" ng-show="!error">{{message}}</p>
				<p class="alert alert-danger" style="text-align: center;" ng-show="error">{{error}}</p>
				<br/><br/><i class="fa fa-spinner fa-spin fa-4x" ng-show="(progress == 'progress' || progress == 'uploading') && !error"></i>
				<button class="btn btn-default btn-lg" ng-show="progress == 'completed' || error" ng-click="onDismissModal()" translate>Close</button>
			</center>
		</modal>
	</div>
</juci-layout-with-sidebar>
